<h2>父母信息设定</h2>
<?php global $setting;?>
<script type="text/javascript">
$(document).ready(function() {
	reloadListener();
    bindAjaxForm($("#s_s_relationship_editform"),s_s_relationship_onSuccess,s_s_relationship_onError,"s_s_profile_dia");
    var data = JSON.parse($(".s_temple_setting.relatioship_settings").html());
  	$.each(data.relations,function(k,v){
  		s_s_addList(v);
  	});
    $(".dropdown").dropdown();
});
function s_s_addList(data){
	try {
	var	ds = $("#s_s_list_temple").clone();
	ds.attr("style", "");
		ds.find(".s_s_child_head").attr("src", data.data.head_image_path);
		ds.find(".s_s_child_name").html(data.data.name).attr("href", getHomeURL(data.data.uid));
		ds.find(".s_s_description").html("关系:您是TA的" + data.relationship);
		$("#s_s_childlist").prepend(ds);
	} catch(err) {
		console.log(err);
		return;
	}
}
function s_s_relationship_onError(data){
	console.log(data);
	showMessage("s_s_relationship_message",-101,data);
}
function s_s_relationship_onSuccess(data){
    try {
        if(data["code"]==0){
        	s_s_addList(data.data);
        }
        showMessage("s_s_relationship_message",data["code"], data["message"]);
    } catch(ex) {
    	showMessage("s_s_relationship_message",-31, data);
    }
}

$('.ui.form').form({
    fields: {
		account: {
			identifier: 'account',
			rules: [{
				type: 'empty',
				prompt: '账户不能为空'
			}]
		},
		passwd: {
			identifier: 'passwd',
			rules: [{
				type: 'minLength[6]',
				prompt: '密码必须大于六位'
			},
			{
				type: 'empty',
				prompt: '密码不能为空'
			}]
		}
    }
});
</script>
<h5>绑定一个子女</h5>
<p>您需要在这里输入子女的账号来协助我们完成验证</p>
<div class="s_temple_setting relatioship_settings"><?php print_json_setting("relationship_settings");?></div>
<div class="ui success message hidden" id="s_s_relationship_message"></div>
<form class="ui form ajaxform" id="s_s_relationship_editform" url="index.php?mod=home&childmod=setting&ajax=ture&op=updaterelationship">
	<div class="field">
		<label>子女账号：</label> <input type="text" name="account" placeholder="子女的账号的uid/邮箱/手机等">
	</div>
	<div class="field">
		<label>子女密码：</label> <input type="password" name="passwd" placeholder="子女的账号的密码">
	</div>
	<div class="field">
		<label>孩子对您的称呼</label>
		<div class="ui selection dropdown">
			<input type="hidden" name="relationship"> <i class="dropdown icon"></i>
			<div class="default text">妈妈</div>
			<div class="menu">
				<div class="item" data-value="妈妈">妈妈</div>
				<div class="item" data-value="爸爸">爸爸</div>
				<div class="item" data-value="爷爷">爷爷</div>
				<div class="item" data-value="奶奶">奶奶</div>
				<div class="item" data-value="姥姥">姥姥</div>
				<div class="item" data-value="老爷">老爷</div>
			</div>
		</div>
	</div>
	<div class="ui error message"></div>
	<button class="ui button" type="submit">保存</button>
</form>
<h5>子女列表</h5>
<div class="ui relaxed divided list" id="s_s_childlist"></div>
<div class="item" id="s_s_list_temple" style="display: none">
	<img class="ui avatar image s_s_child_head">
	<div class='content'>
		<a class="header s_s_child_name"></a>
		<div class="description s_s_description"></div>
	</div>
</div>